package com.yanfan;

import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
import org.eclipse.milo.opcua.stack.core.types.builtin.Variant;
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;

public class OpcUaClientExample {
    public static void main(String[] args) throws Exception {
        OpcUaClient client = OpcUaClient.create("opc.tcp://localhost:4840");
        client.connect().get();

        // 读取节点值（智能照明系统的数据节点）
        NodeId nodeId = new NodeId(2, "YourNodeIDHere");  // 替换为智能照明系统实际的 NodeID
        DataValue value = client.readValue(0, null, nodeId).get();
        System.out.println("Value: " + value.getValue().getValue());

        client.disconnect().get();
    }
}
